/**
 * problem_007.c
 * Copyright (C) 2011-03-18 - xrose
 * The 10001st prime number?
 */
#include <stdio.h>
int main (int argc, char *argv[])
{
    register long long i;
    register int count = 1;
    for (i=3;;i+=2)
    {
        if(isPrime(i))
        {
            count+=1;
            if(count==10001)
            {
                printf("The 10001st prime number: %ld", i);
                break;
            }
        }
    }
    return 0;
}
/*is a prime?*/
int isPrime(long long numb)
{
    long int sqrtnumb = floor(sqrt(numb));
    long int i;
    if(numb < 2)
    {
        return 0;
    } else
        if(numb == 2)
        return 1;
    else
        if(numb%2 == 0) return 0;
    for(i = 3; i<=sqrtnumb; i=i+2)
    {
        if(numb%i == 0)
        {
            return 0;
        }
    }
    return 1;
}
